<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <!-- 引入样式 -->
    <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
    <script src="../js/axios.min.js" type="text/javascript"></script>
    <script src="../js/vue.js" type="text/javascript"></script>
    <script src="https://unpkg.com/element-ui/lib/index.js"></script>
    <title>我的学员</title>
</head>
<body>
<div id="app">
    <!--页面主体-->
    <el-container>
        <el-main>
            <!--展示我的学员-->
            <el-table :data="student" border>
                <el-table-column prop="nickname" label="名称">
                </el-table-column>
                <el-table-column prop="phone" label="联系方式">
                </el-table-column>
                <el-table-column prop="gender" label="性别">
                </el-table-column>
                <el-table-column prop="age" label="年龄">
                </el-table-column>
                <el-table-column label="操作">
                    <template slot-scope="scope">
                        <el-button @click="delStu(scope.row)" type="text" size="small">删除</el-button>
                    </template>
                </el-table-column>
            </el-table>
            <!--分页-->
            <div class="block">
                <el-pagination
                        @size-change="handleSizeChange"
                        @current-change="handleCurrentChange"
                        :current-page="pageInfo.currentPage"
                        :page-sizes="[3, 4]"
                        :page-size="100"
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="pageInfo.total">
                </el-pagination>
            </div>
        </el-main>
    </el-container>
</div>
<script>
    new Vue({
        el: "#app",
        data() {
            return {
                pageInfo: {
                    currentPage: 1,// 当前页
                    size: 3,// 每页多少条
                    total: 1// 总条目数
                },
                student: [],// 所有学员信息

            }
        },
        methods: {
            // 分页 - 更改每页条数
            handleSizeChange(val) {
                this.pageInfo.size = val
                this.query();
            },
            // 分页 - 更改当前页
            handleCurrentChange(val) {
                this.pageInfo.currentPage = val
                this.query();
            },
            // 获取我的所有签约学员
            query() {
                axios.get("/sign/findMyStu?current=" + this.pageInfo.currentPage + "&size=" + this.pageInfo.size).then(resp => {
                    if (resp.status === resp.data.code) {
                        console.log(resp.data.data)
                        this.student = resp.data.data.records
                        this.pageInfo.total = resp.data.data.total
                    }
                })
            },

            delStu(row) {
                axios.delete("/del?id=", this.row.accountId).then(resp => {
                    if (resp.data.code == 200 && resp.status == 200) {
                        alert("成功删除")
                        this.query()
                    }
                })
            }
        },
        created() {
            this.query();
        }
    })
</script>
</body>
</html>